﻿<?xml version="1.0" encoding="utf-8" ?>

<cls:class
	name="Float"
	static="true"
	type="http://metalx.org/Float"
	xmlns="http://metalx.org/Program"
	xmlns:cls="http://metalx.org/Class"
	xmlns:obj="http://metalx.org/i386/Functions/Object"
	xmlns:int="http://metalx.org/i386/Functions/Integer"
	xmlns:float="http://metalx.org/i386/Functions/Float"
	xmlns:lst="http://metalx.org/i386/Functions/List"
	xmlns:str="http://metalx.org/i386/Functions/String"
	xmlns:mm="http://metalx.org/i386/Functions/MemoryManager"
	xmlns:clsf="http://metalx.org/i386/Functions/Class"
	xmlns:var="http://metalx.org/Variable"
	xmlns:sys="http://metalx.org/i386/Functions/System"
	xmlns:cat="http://metalx.org/i386/Functions/Catalog"
	xmlns:asc="http://metalx.org/Ansi/Ascii"
	xmlns:ari="http://metalx.org/Intel/80386/Arithmetic"
	xmlns:math="http://metalx.org/Intel/80386/Math"
	xmlns:imm="http://metalx.org/Intel/80386/Immediate"
	xmlns:shift="http://metalx.org/Intel/80386/Shift"
	xmlns:cpu="http://metalx.org/Intel/80386/Operators"
	xmlns:op="http://metalx.org/Intel/80386/Operands"
	xmlns:fpu="http://metalx.org/Intel/80386/FpuOperators">

	<cls:field name="Value" type="http://metalx.org/Float" offset="0"/>

	<cls:method name="Zero" type="http://metalx.org/Float" static="true">
		<fpu:ResetFpu/>

		<fpu:Zero/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="One" type="http://metalx.org/Float" static="true">
		<fpu:ResetFpu/>

		<fpu:One/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="NegativeOne" type="http://metalx.org/Float" static="true">
		<fpu:ResetFpu/>

		<fpu:One/>

		<fpu:ChangeSign/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Squared" type="http://metalx.org/Float">		
		<fpu:ResetFpu/>

		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:MultiplyST0ByST0/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="MaxValue" type="http://metalx.org/Float" static="true">
		<fpu:ResetFpu/>

		<fpu:PushFloatAtImmediateAddressToST0/>
		<addressOf ref="maxValue" type="Absolute32"/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>

		<label id="maxValue"/>
		<float>340282300000000000000000000000000000000</float>
	</cls:method>

	<cls:method name="MinValue" type="http://metalx.org/Float" static="true">
		<fpu:ResetFpu/>

		<fpu:PushFloatAtImmediateAddressToST0/>
		<addressOf ref="minValue" type="Absolute32"/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>

		<label id="minValue"/>
		<float>-340282300000000000000000000000000000000</float>
	</cls:method>

	<cls:method name="Epsilon" type="http://metalx.org/Float" static="true">
		<fpu:ResetFpu/>

		<fpu:PushFloatAtImmediateAddressToST0/>
		<addressOf ref="epsilon" type="Absolute32"/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>

		<label id="epsilon"/>
		<float>0.000000000000000000000000000000000000000000014</float>
	</cls:method>

	<cls:method name="Pi" type="http://metalx.org/Float" static="true">
		<fpu:ResetFpu/>

		<fpu:Pi/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="PiOverTwo" type="http://metalx.org/Float" static="true">
		<fpu:ResetFpu/>

		<fpu:Pi/>

		<fpu:One/>

		<fpu:AddST0ToST0/>

		<fpu:DivideST1ByST0AndIncrementST/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="PiOverFour" type="http://metalx.org/Float" static="true">
		<fpu:ResetFpu/>

		<fpu:Pi/>

		<fpu:One/>

		<fpu:AddST0ToST0/>
		<fpu:AddST0ToST0/>
		
		<fpu:DivideST1ByST0AndIncrementST/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="ThreePiOverTwo" type="http://metalx.org/Float" static="true">
		<fpu:ResetFpu/>

		<fpu:Pi/>
		<fpu:Pi/>

		<fpu:AddST0ToST0/>
		<fpu:AddST0ToST1AndIncrementST/>

		<fpu:One/>
		<fpu:AddST0ToST0/>

		<fpu:DivideST1ByST0AndIncrementST/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="TwoPi" type="http://metalx.org/Float" static="true">
		<fpu:ResetFpu/>

		<fpu:Pi/>

		<fpu:AddST0ToST0/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Sine" type="http://metalx.org/Float">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:Sine/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Cosine" type="http://metalx.org/Float">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:Cosine/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Tangent" type="http://metalx.org/Float">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:Tangent/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Arctangent" type="http://metalx.org/Float">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:Arctangent/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="SquareRoot" type="http://metalx.org/Float">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:SquareRoot/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Sine" type="http://metalx.org/Float" static="true">
		<cls:parameter name="Value" type="http://metalx.org/Float"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:Sine/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Cosine" type="http://metalx.org/Float" static="true">
		<cls:parameter name="Value" type="http://metalx.org/Float"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:Cosine/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Tangent" type="http://metalx.org/Float" static="true">
		<cls:parameter name="Value" type="http://metalx.org/Float"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:Tangent/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Arctangent" type="http://metalx.org/Float" static="true">
		<cls:parameter name="Value" type="http://metalx.org/Float"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:Arctangent/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="SquareRoot" type="http://metalx.org/Float" static="true">
		<cls:parameter name="Value" type="http://metalx.org/Float"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:SquareRoot/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="ToDegrees" type="http://metalx.org/Float" static="true">
		<cls:parameter name="Value" type="http://metalx.org/Float"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:PushFloatAtImmediateAddressToST0/>
		<addressOf ref="radiansToDegrees" type="Absolute32"/>

		<fpu:MultiplyST1ByST0AndIncrementST/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>

		<var:float id="radiansToDegrees">57.295779513082320876798154814105</var:float>
	</cls:method>

	<cls:method name="ToRadians" type="http://metalx.org/Float" static="true">
		<cls:parameter name="Value" type="http://metalx.org/Float"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:PushFloatAtImmediateAddressToST0/>
		<addressOf ref="degreesToRadians" type="Absolute32"/>

		<fpu:MultiplyST1ByST0AndIncrementST/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>

		<var:float id="degreesToRadians">0.017453292519943295769236907684886</var:float>
	</cls:method>

	<!--<cls:method name="WrapDegrees" type="http://metalx.org/Float" static="true">
		<cls:parameter name="Value" type="http://metalx.org/Float"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:SquareRoot/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="WrapRadians" type="http://metalx.org/Float" static="true">
		<cls:parameter name="Value" type="http://metalx.org/Float"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushFloatAtSIAddressToST0/>

		<fpu:SquareRoot/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>-->

	<cls:method name="InterpolateLinear" type="http://metalx.org/Float" static="true">
		<cls:parameter name="Value1" type="http://metalx.org/Float"/>
		<cls:parameter name="Value2" type="http://metalx.org/Float"/>
		<cls:parameter name="Amount" type="http://metalx.org/Float"/>

		<fpu:ResetFpu/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<obj:GetData/>
		
		<fpu:PushFloatAtSIAddressToST0/>

		<cpu:WaitForFloatingPointUnit/>

		<cpu:PullSIFromStack/>

		<obj:GetData/>

		<fpu:PushFloatAtSIAddressToST0/>

		<cpu:WaitForFloatingPointUnit/>

		<cpu:PullSIFromStack/>

		<obj:GetData/>

		<fpu:PushFloatAtSIAddressToST0/>
		
		<cpu:WaitForFloatingPointUnit/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<fpu:SubtractST0FromST1/>

		<fpu:ExchangeST2WithST0/>

		<fpu:MultiplyST1ByST0AndIncrementST/>

		<fpu:AddST0ToST1AndIncrementST/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="ToString" type="http://metalx.org/String">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>
		
		<fpu:PushFloatAtSIAddressToST0/>

		<float:ToString/>

		<str:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetClass" type="http://metalx.org/Class">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetType/>

		<cpu:CopyRegisterToOperand/>
		<op:SI-DIRegister/>

		<clsf:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetClass" type="http://metalx.org/Class" static="true">
		<cpu:CopyRegisterToOperand/>
		<op:BX-DIRegister/>

		<clsf:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>
</cls:class>